<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var arr = [1,1,'true','true',true,true,15,15,false,false, undefined,undefined, null,null, NaN, NaN,'NaN', 0, 0, 'a', 'a',{},{}];
    // set去重 不能对对象去重
   function unique(arr){
     return [...new Set(arr)]
   }
   // filter 去重
   function unique1(arr){
     return arr.filter(function(item,index,array){
       return array.indexOf(item) === index
     })
   }

function arrayUnique2(arr) {
  let res= []
  let hash= {}
  for(let i =0 ;i< arr.length;i++){
    let item = arr[i]
    let key = typeof(item) + item
    if(hash[key] !=1){
      res.push(item)
      hash[key] = 1;
    }
  }
  return res
}
   console.log(unique(arr))
   console.log(unique1(arr))
   console.log(arrayUnique2(arr))
  </script>
</body>
</html>